package com.xu.cloud.common.tx;

import org.apache.ibatis.session.SqlSession;

/**
 * SqlSession事务管理
 *
 * @author xuguan
 * @since 2024/11/8
 * @see org.apache.ibatis.session.SqlSession
 */
public class SqlSessionITransaction implements ITransaction {

    private final SqlSession sqlSession;

    public SqlSessionITransaction(SqlSession sqlSession) {
        this.sqlSession = sqlSession;
    }


    @Override
    public void startTransaction() {
    }

    @Override
    public void commit() {
       sqlSession.commit();
    }

    @Override
    public void rollback() {
        sqlSession.rollback();
    }

    @Override
    public void endTransaction() {
        sqlSession.close();
    }
}
